/*
 * TwoEntry.cpp
 *
 * Created on: 05-05-2014
 *     Author: A.W. Janisse
 *
 * Version 1.0: 24-05-2014, Final release
 */

#include "TwoEntry.h"

TwoEntry::TwoEntry(int x, int y, string type)
:Gate(x, y, type), entry1(NULL), entry2(NULL)
{
}

Gate * TwoEntry::getEntry(int nr)
{
    if(nr == 0)
        return entry1;
    else if (nr == 1)
        return entry2;
    else
        return NULL;
}

bool TwoEntry::connectEntryTo(Gate *gate)
{
    if(entry1 == NULL){
       entry1 = gate;
       return true;
    }
   else if (entry2 == NULL) {
       entry2 = gate;
       return true;
   } else
        return false;
}

bool TwoEntry::removeEntryTo(Gate *gate)
{
    if(entry1 != NULL && entry1->getNumber() == gate->getNumber()){
        entry1 = NULL;
        return true;
    }else if (entry2 != NULL && entry2->getNumber() == gate->getNumber()){
        entry2 = NULL;
        return true;
    } else
        return false;
}
